package com.myidis.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myidis.request.CheckReq;
import com.myidis.request.CorrelationReq;
import com.myidis.request.PeakValleyReq;
import com.myidis.request.BBReq;
import com.myidis.request.SeasonAdjustReq;
import com.myidis.response.BBRes;
import com.myidis.response.CorrelationRes;
import com.myidis.response.PeakValleyRes;
import com.myidis.response.SeasonAdjustRes;
import com.myidis.response.StatisticsRes;
import com.myidis.servlet.AnalysisServlet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/analysis")
@Api(tags = "基本分析工具接口")
public class AnalysisController {
	@Autowired
	private AnalysisServlet analysisServlet;
	
	@ResponseBody
	@ApiOperation("对数据进行完整性检查")
	@RequestMapping(value="/check",method=RequestMethod.POST,consumes= MediaType.APPLICATION_JSON_VALUE)
	public Integer check(@RequestBody CheckReq req) {
		return analysisServlet.check(req);
	}
	
	@ResponseBody
	@ApiOperation("进行基本统计量计算")
	@RequestMapping(value="/statistics",method=RequestMethod.POST,consumes= MediaType.APPLICATION_JSON_VALUE)
	public List<StatisticsRes> statistics(@RequestBody CheckReq req) {
		return analysisServlet.statistics(req);
	}
	
	@ResponseBody
	@ApiOperation("进行季节调整")
	@RequestMapping(value="/season",method=RequestMethod.POST,consumes= MediaType.APPLICATION_JSON_VALUE)
	public SeasonAdjustRes season(@RequestBody SeasonAdjustReq req) {
		return analysisServlet.seasonAdjust(req);
	}
	
	@ResponseBody
	@ApiOperation("进行相关性分析")
	@RequestMapping(value="/correlation",method=RequestMethod.POST,consumes= MediaType.APPLICATION_JSON_VALUE)
	public CorrelationRes correlation(@RequestBody CorrelationReq req) {
		return analysisServlet.correlation(req);
	}
	
	@ResponseBody
	@ApiOperation("通过BB算法进行谷峰计算")
	@RequestMapping(value="/bb",method=RequestMethod.POST,consumes= MediaType.APPLICATION_JSON_VALUE)
	public BBRes bb(@RequestBody BBReq req) {
		return analysisServlet.calcBB(req);
	}
	
	@ResponseBody
	@ApiOperation("通过所给谷峰进行结果计算")
	@RequestMapping(value="//pv",method=RequestMethod.POST,consumes= MediaType.APPLICATION_JSON_VALUE)
	public List<PeakValleyRes> peakValley(@RequestBody PeakValleyReq req) {
		return analysisServlet.calcPeakValley(req);
	}
}
